home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
FILER
/
X-FILES.ZIP
/
057
/
!X-Files
/
c
/
debug
< prev
next >
Wrap
Text File
|
1996-03-25
|
2KB
|
88 lines
/* debug.c */
#include "debug.h"
#include "kernel.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#ifndef Tracker_Open
#define Tracker_Open 0xCF000
#define Tracker_Close 0xCF001
#define Tracker_SetPos 0xCF002
#define Tracker_WriteS 0xCF003
#define Tracker_CLS 0xCF004
#define Tracker_Simple 0xCF005
#endif
int SavedSP;
static int __trackHandle = 0;
static int __open(char *title, int width, int height, int flags)
{
_kernel_swi_regs regs;
_kernel_oserror *err;
regs.r[0] = (int) title;
regs.r[1] = width;
regs.r[2] = height;
regs.r[3] = flags;
if (err = _kernel_swi(Tracker_Open, ®s, ®s), err)
return -1;
return regs.r[0];
}
static void __close(int handle)
{
_kernel_swi_regs regs;
regs.r[0] = handle;
(void) _kernel_swi(Tracker_Close, ®s, ®s);
}
static void __writes(int handle, const char *s)
{
_kernel_swi_regs regs;
regs.r[0] = handle;
regs.r[1] = (int) s;
(void) _kernel_swi(Tracker_WriteS, ®s, ®s);
}
static void __exithandler(void)
{ if (__trackHandle)
__close(__trackHandle);
}
static void __outs(const char *s)
{
if (__trackHandle == 0)
{ if (__trackHandle = __open("X-Files", 80, 5000, 1), __trackHandle > 0)
atexit(__exithandler);
else
return;
}
else if (__trackHandle < 0)
return;
__writes(__trackHandle, s);
}
/* External interface */
void TRACE(const char *fmt, ...)
{
va_list ap;
char buf[300];
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
va_end(ap);
__outs(buf);
}